<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>区域操作</title>
    <script src="../../res/js/jquery-3.4.1.min.js"></script>
    <script src="../../res/layui/layui.js" charset="utf-8"></script>
    <script src="../../res/js/Tools.js"></script>
    <link rel="stylesheet" href="../../res/layui/css/layui.css" media="all">
    <style type="text/css">
        body {
            padding: 10px;
        }
        .fonts {
            line-height: 40px;
        }
    </style>

</head>
<body>
<form class="layui-form" action="">
    <div class="layui-form-item">

        <div class="layui-inline">
            <label class="layui-form-label">标题:</label>
            <div class="layui-input-inline">
                <div class="fonts" id="clientId">

                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">内容:</label>
        <div class="layui-input-block">
            <div class="fonts" id="clientName">

            </div>
        </div>
    </div>
</form>
<script type="text/javascript">

</script>
<script>
    layui.use(['form', 'layedit', 'laydate','layer','element'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , element = layui.element;

        //监听提交
        form.on('submit(demo1)', function (data) {
            var url = "../../houseOrClientAction/add";
            $.post(url, data.field, function (obj) {
                if (obj.num == 1) {
                    window.parent.location.reload();//刷新父页面
                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);
                }
            }, "json")
            return false;
        });


        //表单取值
        layui.$('#LAY-component-form-getval').on('click', function () {
            var data = form.val('example');
            alert(JSON.stringify(data));
        });


        // 修改赋值
        var houseClientId = getQueryString("houseClientId");
        if (houseClientId) {
            var url = "../../houseOrClientAction/findById";
            var data = {"houseClientId": houseClientId};
            $.post(url, data, function (obj) {
                $("#clientId").html(obj.clientId);// 通知标题
                $("#clientName").html(obj.clientName);// 通知内容
                element.init();
            }, "json")
        }

    });
</script>
</body>
</html>